<!--Header Starts Here-->
<div id="u_header">
    <div id="u_container">
        <div id="u_box">
            <div id="u_top">
                <div id="u_search" align="center">
                    <p>Anbefalinger <i>Justert</i> for Markedskreftene</p>
                    <form class="search" action="search">
                        <input type="text" placeholder="Type Something..."  name="search" autofocus="autofocus" required="required"   />
                        <input type="submit" value="Search company" name="company" />
                        <input type="submit" value="Best Performer" name="performer" />
                        <input type="submit" value="Search analyst" name="analyst" />
                    </form>
                </div>
            </div>
            <!--Broker Container Starts Here-->
            <div id="service_box">
                <h2 align="center" style="color:#f4421a; margin-top:50px;">List of Analyst</h2>

                <?php foreach ($list_brokers as $broker): ?>
                    <div id="analyst"><!--analyst Start-->
                        <div id="a_name"><?php echo $broker['Broker']['fullname'] ?></div>

                        <?php if (isset($broker['Broker']['stock'])): ?>
                            <p><b><?php echo $broker['Broker']['stock']['Stock']['name']; ?></b></p>
                            <div id="a_details">
                                <?php if ($broker['Broker']['stock']['Stock']['values']): ?>
                                    <?php $current_value = $broker['Broker']['stock']['Stock']['values'][0]['StockValues']['closing']; ?>
                                    <?php $previous_value = 0; ?>
                                    <p align="left">Curent Value = <?php echo $current_value; ?></p>
                                    <?php
                                    if (isset($broker['Broker']['stock']['Stock']['values'][1])) {
                                        $previous_value = $broker['Broker']['stock']['Stock']['values'][1]['StockValues']['closing'];
                                        echo '<p align="right">On ' . date('d/m/Y', strtotime($broker['Broker']['stock']['Stock']['values'][1]['StockValues']['date'])) . ' = ' . $previous_value . '</p>';
                                    }
                                    echo '<p style = "">Previous Difference<br />';
                                    if ($current_value != $previous_value) {
                                        echo '<i style="color:#0C3;">Green</i>';
                                    } else {
                                        echo '<i style="color:#C33;">Red</i> ';
                                    }
                                    ?>
                                    </p>

                                <?php endif; ?>
                            </div>
                        <?php else: ?>
                            <p><b>&nbsp;</b></p>
                            <div id="a_details"></div>
                        <?php endif; ?>

                        <p align="center" id="a_register"><?php echo $this->Html->link('View Profile', '/analyst/view/' . $broker['Broker']['id']); ?></p>
                    </div> <!--analyst End -->
                <?php endforeach; ?> 

                <!--analyst 1 End--> 

                <h2 align="center" style="color:#f4421a; margin-top:50px;">List of Company</h2>

                <?php foreach ($list_companies as $company): ?>
                    <div id="company"><!--Company Start-->

                        <div id="c_name"><?php echo $company['Company']['name'] ?></div>
                        <p>Total Broker <?php echo $company['Company']['brokers'] ?></p>
                        <div id="b_details">
                            <p><?php echo $company['Company']['short_description'] ?></p>

                        </div>
                        <p align="center" id="c_register"><?php echo $this->Html->link('View Profile', '/company/view/' . $company['Company']['id']); ?></p>
                    </div>
                    <!--Company End--> 
                <?php endforeach; ?>



                <!--Company 1 End--> 
                <h2 align="center" style="color:#f4421a; margin-top:50px;">List of Performer</h2>
                <div id="performer"><!--Performer 1 Start-->

                    <div id="p_name">Broker's Name <h4>Rank 1</h4> </div>
                    <p>Performance</p>
                    <div id="b_details">
                        <div id="green" style="width:<?Php echo "75%"; ?>; background-color:#093;"><?php echo "75%"; ?></div>
                        <div id="red" style=" width:<?php echo "25%"; ?>; background-color:rgba(204,51,0,1);"><?php echo "25%"; ?></div>

                    </div>
                    <p align="center" id="p_register"><a href="">View Profile</a></p>
                </div>

                <!--Performer 1 End--> 
                <div id="performer"><!--Performer 1 Start-->

                    <div id="p_name">Broker's Name <h4>Rank 2</h4> </div>
                    <p>Performance</p>
                    <div id="b_details">
                        <div id="green" style="width:<?Php echo "75%"; ?>; background-color:#093;"><?php echo "75%"; ?></div>
                        <div id="red" style=" width:<?php echo "25%"; ?>; background-color:rgba(204,51,0,1);"><?php echo "25%"; ?></div>

                    </div>
                    <p align="center" id="p_register"><a href="">View Profile</a></p>
                </div>

                <!--Performer 1 End--> 
                <div id="performer"><!--Performer 1 Start-->

                    <div id="p_name">Broker's Name <h4>Rank 3</h4> </div>
                    <p>Performance</p>
                    <div id="b_details">
                        <div id="green" style="width:<?Php echo "75%"; ?>; background-color:#093;"><?php echo "75%"; ?></div>
                        <div id="red" style=" width:<?php echo "25%"; ?>; background-color:rgba(204,51,0,1);"><?php echo "25%"; ?></div>

                    </div>
                    <p align="center" id="p_register"><a href="">View Profile</a></p>
                </div>

                <!--Performer 1 End--> 

                <!--=========Pagination Start Here ========-->
                <div id="pagination"><p>1&nbsp;2&nbsp;3...</p></div>
                <!--=========Pagination Ends Here ========-->
            </div>
            <!--Broker Container Starts Here--> 

        </div>
    </div></div>

<!--Header Ends Here-->
    
<!--Registration Coding Ends Here-->
<?php echo $this->element('footer'); ?>

<script>
    $(document).ready(function(e) {


        if ($(window).width() > 768) {

// Hide all but first tab content on larger viewports
            $('.accordion__content:not(:first)').hide();

// Activate first tab
            $('.accordion__title:first-child').addClass('active');

        } else {

// Hide all content items on narrow viewports
            $('.accordion__content').hide();
        }
        ;

// Wrap a div around content to create a scrolling container which we're going to use on narrow viewports
        $(".accordion__content").wrapInner("<div class='overflow-scrolling'></div>");

// The clicking action
        $('.accordion__title').on('click', function() {
            $('.accordion__content').hide();
            $(this).next().show().prev().addClass('active').siblings().removeClass('active');
        });

    });
    $(function() {

        $(' #da-thumbs > li ').each(function() {
            $(this).hoverdir();
        });

    });
</script>
